<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/9/6
 * Time: 14:43
 */

namespace app\admin_fussen\model;

use app\common\model\Base;
use think\Db;

class BasicAddress extends Base
{
    /**
     * 获取省份名称
     * @param $value
     * @param $data
     * @return mixed
     */
    public function getProvinceTextAttr($value, $data)
    {
        $value = isset($data['province']) ? $data['province'] : $value;
        return Db::name('basic_region')->where('id', $value)->value('area_name');
    }

    /**
     * 获取城市名称
     * @param $value
     * @param $data
     * @return mixed
     */
    public function getCityTextAttr($value, $data)
    {
        $value = isset($data['city']) ? $data['city'] : $value;
        return Db::name('basic_region')->where('id', $value)->value('area_name');
    }

    /**
     * 获取区/县名称
     * @param $value
     * @param $data
     * @return mixed
     */
    public function getDistrictTextAttr($value, $data)
    {
        $value = isset($data['district']) ? $data['district'] : $value;
        return Db::name('basic_region')->where('id', $value)->value('area_name');
    }

}